package simpleeditor.model;

import java.util.Hashtable;
import java.util.Map;


public class GroupManager {

	private Map<String,Group> groups=new Hashtable<String,Group>();
	
	public String newGroup() {
		Group newGroup;
		String groupId;
		
		newGroup=new Group();
		groupId=newGroup.getName();
		
		groups.put(groupId, newGroup);
		
		return groupId;
	}

	public Group getGroup(String groupId) {
		return groups.get(groupId);
	}

	public Group removeGroup(String group) {
		return groups.remove(group);
	}

	public boolean addGroup(Group g) {
		if((g!=null)
		  &&(groups.get(g.getName())==null)){
			groups.put(g.getName(), g);
			return true;
		}else{
			return false;
		}
		
	}

}
